#version 430 core

//precision highp float;

layout (location = 0) in vec3 _Position;
layout (location = 1) in mat4 _InstanceModel;

uniform mat4 u_ModelMatrix;
layout(std140, binding = 0) uniform u_Matrices4ProjectionWorld
{
	mat4 u_ProjectionMatrix;
	mat4 u_ViewMatrix;
};

out vec3 v2f_RayAABBEntry;
out vec3 v2f_AABBOffset;

void main()
{
	gl_Position = u_ProjectionMatrix * u_ViewMatrix * u_ModelMatrix * _InstanceModel * vec4(_Position * 0.5, 1.0f);
	v2f_AABBOffset = _InstanceModel[3].xyz;
	v2f_RayAABBEntry = vec3(_InstanceModel * vec4(_Position * 0.5f, 1.0f));
}